<template>
  <div class="layout-container">
    <router-view />
    <van-tabbar v-model="active" route v-if="$route.meta.showTabbar">
      <van-tabbar-item to="/home" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item to="/approval" icon="notes-o">审批</van-tabbar-item>
      <van-tabbar-item to="/mine" icon="contact">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: 'Layout',
  data() {
    return {
      active: 0
    }
  },
  created() {
    // 根据当前路由设置初始激活项
    const path = this.$route.path
    if (path === '/home') {
      this.active = 0
    } else if (path === '/approval') {
      this.active = 1
    } else if (path === '/mine') {
      this.active = 2
    }
  }
}
</script>

<style scoped>
.layout-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
</style>